﻿using System;
using System.Windows.Threading;

namespace Core.Mvvm.ViewModels
{
    public abstract class BaseViewModel : NotifiedObject, IViewModel
    {
        #region Fields

        private string _displayName;
        private readonly Dispatcher _dispatcher;

        #endregion

        #region Properties

        public Dispatcher Dispatcher
        {
            get { return _dispatcher; }
        }

        public string DisplayName
        {
            get { return _displayName; }
            set { SetProperty(ref _displayName, value, () => this.DisplayName); }
        }

        #endregion

        #region Constructors

        protected BaseViewModel(Dispatcher dispatcher)
        {
            if (ReferenceEquals(dispatcher, null))
            {
                throw new ArgumentNullException();
            }
            _dispatcher = dispatcher;
        }

        #endregion

        #region Methods

        protected virtual void OnDispose()
        {
        }

        public void Dispose()
        {
            OnDispose();
        }

        #endregion
    }
}
